package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CommentConfigDto;
import com.heima.model.wemedia.dtos.CommentLikeDto;
import com.heima.model.wemedia.dtos.CommentManageDto;
import com.heima.model.wemedia.dtos.PageCommentDto;
import com.heima.wemedia.service.WmCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class WmCommentController {
    @Autowired
    private WmCommentService wmCommentService;

    /**
     * 查看评论列表
     *
     * @param pageCommentDto
     * @return {@link ResponseResult}
     */
    @PostMapping("/find_news_comments")
    public ResponseResult findNewsComments(@RequestBody PageCommentDto pageCommentDto) {
        return wmCommentService.findNewsComments(pageCommentDto);
    }

    /**
     * 打开或关闭评论
     *
     * @param dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/update_comment_status")
    public ResponseResult updateCommentStatus(@RequestBody CommentConfigDto dto) {
        return wmCommentService.updateCommentStatus(dto);
    }

    /**
     * 查看文章评论详情
     *
     * @param dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody CommentManageDto dto) {
        return wmCommentService.list(dto);
    }

    /**
     * 评论点赞
     * @param commentLikeDto
     * @return {@link ResponseResult}
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto commentLikeDto) {
        return wmCommentService.like(commentLikeDto);
    }
}
